package edu.towson.cosc.cosc455.jsmole1.markdowncompiler;

import java.util.Arrays;
import java.util.List;

/** A class consisting of all tags used in the markdown document */
public class Tag {
	
	final static String STARTDOC = "#START DOCUMENT";
	final static String ENDDOC = "#END DOCUMENT";
	
	final static String STARTHEAD = "#START HEAD";
	final static String ENDHEAD = "#END HEAD";
	
	final static String STARTTITLE = "#START TITLE";
	final static String ENDTITLE = "#END TITLE";
	
	final static String STARTPAR = "#START PARAGRAPH";
	final static String ENDPAR = "#END PARAGRAPH";
	
	final static String STARTBOLD = "#START BOLD";
	final static String ENDBOLD = "#END BOLD";
	
	final static String STARTITALICS = "#START ITALICS";
	final static String ENDITALICS = "#END ITALICS";
	
	final static String STARTLIST = "#START LIST";
	final static String ENDLIST = "#END LIST";
	
	final static String STARTITEM = "#START ITEM";
	final static String ENDITEM = "#END ITEM";
	
	final static String STARTAUDIO = "#START AUDIO";
	final static String ENDAUDIO = "#END AUDIO";
	
	final static String STARTVIDEO = "#START VIDEO";
	final static String ENDVIDEO = "#END VIDEO";
	
	final static String STARTDEFINE = "#START DEFINE";
	final static String ENDDEFINE = "#END DEFINE";
	
	final static String STARTUSE = "#START USE";
	final static String ENDUSE = "#END USE";
	
	final static String NEWLINE = "#NEWLINE";
	final static String NAME = "#NAME";
	final static String VALUE = "#VALUE";
	
	// http://stackoverflow.com/questions/1005073/initialization-of-an-arraylist-in-one-line
	public static List<String> tags = Arrays.asList(
			STARTDOC, ENDDOC, 
			STARTHEAD, ENDHEAD,
			STARTTITLE, ENDTITLE,
			STARTPAR, ENDPAR,
			STARTBOLD, ENDBOLD,
			STARTITALICS, ENDITALICS,
			STARTLIST, ENDLIST,
			STARTITEM, ENDITEM,
			STARTAUDIO, ENDAUDIO,
			STARTVIDEO, ENDVIDEO,
			STARTDEFINE, ENDDEFINE,
			STARTUSE, ENDUSE,
			NEWLINE,
			NAME,
			VALUE);
	
	/**
	 * Used in combination with the variable parse tree to find the corresponding start tag
	 * @param tag end tag to compare with
	 * @return start tag that matches the given end tag
	 */
	public static String findPair(String tag) {
		
		if (tag.equalsIgnoreCase(ENDDOC))
			return STARTDOC;
		else if (tag.equalsIgnoreCase(ENDHEAD))
			return STARTHEAD;
		else if (tag.equalsIgnoreCase(ENDTITLE))
			return STARTTITLE;
		else if (tag.equalsIgnoreCase(ENDPAR))
			return STARTPAR;
		else if (tag.equalsIgnoreCase(ENDBOLD))
			return STARTBOLD;
		else if (tag.equalsIgnoreCase(ENDITALICS))
			return STARTITALICS;
		else if (tag.equalsIgnoreCase(ENDLIST))
			return STARTLIST;
		else if (tag.equalsIgnoreCase(ENDITEM))
			return STARTITEM;
		else if (tag.equalsIgnoreCase(ENDAUDIO))
			return STARTAUDIO;
		else if (tag.equalsIgnoreCase(ENDVIDEO))
			return STARTVIDEO;
		else if (tag.equalsIgnoreCase(ENDDEFINE))
			return STARTDEFINE;
		else if (tag.equalsIgnoreCase(ENDUSE))
			return STARTUSE;		
		
		return "";
	}

}
